import { Window } from "../../../component/window/Window";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { CopyResultBg } from "../common/displayBg/CopyResultBg";
import { Cache } from "../../cache/Cache";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { BgItem } from "../common/BgItem";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { Language } from "../../../../extend/language/Language";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SNewBattleFieldMyResult } from "../../../../Message/Public/SNewBattleFieldMyResult";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class NewBattlefiledMyResultWindow
    
    export  class NewBattlefiledMyResultWindow extends Window
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(652, 351);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.EmbedNumberName, 24, 15788607);
            var loc2=new GTextFormat(FontUtil.EmbedNumberName, 18, 15788607);
            this._copyResultBg = new CopyResultBg(Cache.instance.role.entityInfo.sex);
            this.addChild(this._copyResultBg);
            this._bmpTitle = ObjCreate.createBitmap("", 189, 5, this);
            this._bmpRank = ObjCreate.createBitmap("", 363, 21, this);
            this._tfTextRank = ObjCreate.createTextField("", 422, 23, 53, 20, this, GlobalStyle.textFormat6);
            this._tfRank = ObjCreate.createTextField("", 467, 18, 50, 20, this, loc1);
            this._tfRank.embedFonts = true;
            this._bmpTotleHonor = ObjCreate.createBitmap("", 193, 55, this);
            this._tfTotleHonor = ObjCreate.createTextField("", 264, 55, 100, 20, this, loc1);
            this._tfTotleHonor.embedFonts = true;
            this._tfHonorAddition = ObjCreate.createTextField("", 350, 59, 200, 20, this, GlobalStyle.textFormatGreen);
            this._bmpBattleHonor = ObjCreate.createBitmap("", 192, 87, this);
            this._tfHonor = ObjCreate.createTextField("", 267, 94, 100, 20, this, loc2);
            this._bmpWinHonor = ObjCreate.createBitmap("", 375, 87, this);
            this._tfWinHonor = ObjCreate.createTextField("", 455, 87, 100, 20, this, loc2);
            var loc3=GlobalStyle.textFormat6;
            loc3.leading = 7;
            this._tfWinText = ObjCreate.createTextField("", 455, 110, 70, 40, this, loc3);
            this._tfWinText.multiline = true;
            this._tfWinText.wordWrap = true;
            this._bmpTowerHonor = ObjCreate.createBitmap("", 192, 159, this);
            this._tfTowerHonor = ObjCreate.createTextField("", 270, 160, 100, 20, this, loc2);
            this._towerNumber = new TowerNumber();
            this._towerNumber.x = 267;
            this._towerNumber.y = 181;
            this.addChild(this._towerNumber);
            this._bmpDefenceTowerHonor = ObjCreate.createBitmap("", 375, 159, this);
            this._defenceTowerHonor = ObjCreate.createTextField("", 454, 160, 100, 20, this, loc2);
            this._defenceTowerNumber = new TowerNumber();
            this._defenceTowerNumber.x = 448;
            this._defenceTowerNumber.y = 181;
            this.addChild(this._defenceTowerNumber);
            this._bmpBattleReward = ObjCreate.createBitmap("", 184, 252, this);
            this._bgItem = new BgItem();
            ObjCreate.setObjAttri(this._bgItem, 283, 245, -1, -1, this);
            LoaderHelp.addResCallBack(ResFileConst.newBattlefieldResult, this.resCompl);
            this._btnTop = ObjCreate.createGButton(Language.getString(41664), 415, 253, 70, 26, this);
            this._btnLeave = ObjCreate.createGButton(Language.getString(41665), 500, 253, 70, 26, this);
            this._btnTop.addEventListener(flash.events.MouseEvent.CLICK, this.onClickTop);
            this._btnLeave.addEventListener(flash.events.MouseEvent.CLICK, this.onClickLeave);
            return;
        }

        /* internal  */resCompl(): void
        {
            this._bmpTitle.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultTitle);
            this._bmpRank.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultRank);
            this._bmpTotleHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultTotalHonor);
            this._bmpBattleHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultHonor);
            this._bmpTowerHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultAttackTower);
            this._bmpDefenceTowerHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultDefenceTower);
            this._bmpBattleReward.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultReward);
            this._towerNumber.towerBitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultTower);
            this._defenceTowerNumber.towerBitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultTower);
            this._isResCompl = true;
            this.updateWinBmp();
            return;
        }

        /* internal  */updateWinBmp(): void
        {
            if (this._isResCompl && this._result) 
            {
                if (this._result.win) 
                {
                    this._bmpWinHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultWin);
                }
                else 
                {
                    this._bmpWinHonor.bitmapData = GlobalClass.getBitmapData(ImagesConst.newBattlefieldResultLost);
                }
            }
            return;
        }

        /* internal  */onClickTop(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.NewBattlefieldAutoShowOrHideTop));
            return;
        }

        /* internal  */onClickLeave(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.NewBattlefieldRequestLeaveAffirm));
            return;
        }

        public updateResult(arg1: SNewBattleFieldMyResult): void
        {
            this._result = arg1;
            this.show();
            this._tfTextRank.text = arg1.win ? Language.getString(41685) : Language.getString(41686);
            this._tfRank.text = arg1.rank.toString();
            this._tfTotleHonor.text = arg1.honour.toString();
            this._tfHonorAddition.text = Language.getStringByParam(41687, arg1.vipHonour.toString(), arg1.inspireHonour.toString());
            this._tfHonor.text = "+" + arg1.fightHonour.toString();
            this._tfWinHonor.text = "+" + arg1.winHonour.toString();
            this._tfWinText.htmlText = Language.getString(41688) + (arg1.win ? Language.getString(41689) : Language.getString(41690));
            this._tfTowerHonor.text = "+" + arg1.towerHonour.toString();
            this._towerNumber.num = arg1.killTower;
            this._defenceTowerHonor.text = "+" + arg1.protectTowerHonour.toString();
            this._defenceTowerNumber.num = arg1.leftTower;
            this._bgItem.setItemCode(arg1.rewardItem);
            this.updateWinBmp();
            return;
        }

        /* internal */ /* var */_copyResultBg: CopyResultBg;

        /* internal */ /* var */_bmpTitle: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpRank: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfTextRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpTotleHonor: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfTotleHonor: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfHonorAddition: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpBattleHonor: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfHonor: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpWinHonor: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfWinHonor: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWinText: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpTowerHonor: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfTowerHonor: Object /* flash.text.TextField */;

        /* internal */ /* var */_towerNumber: TowerNumber;

        /* internal */ /* var */_bmpDefenceTowerHonor: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_defenceTowerHonor: Object /* flash.text.TextField */;

        /* internal */ /* var */_defenceTowerNumber: TowerNumber;

        /* internal */ /* var */_bmpBattleReward: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bgItem: BgItem;

        /* internal */ /* var */_btnTop: GButton;

        /* internal */ /* var */_btnLeave: GButton;

        /* internal */ /* var */_isResCompl: Boolean=false;

        /* internal */ /* var */_result: SNewBattleFieldMyResult;
    }
}


class TowerNumber extends flash.display.Sprite
{
    public TowerNumber()
    {
        super();
        this._bmpTower = new Object /* flash.display.Bitmap */();
        this.addChild(this._bmpTower);
        var loc1=new GTextFormat(FontUtil.EmbedNumberName, 20, 15788607);
        this._tfNum = ObjCreate.createTextField("", 22, 15, 70, 25, this, loc1);
        this._tfNum.embedFonts = true;
        return;
    }

    public set num(arg1: int)
    {
        this._tfNum.htmlText = "X " + arg1.toString();
        return;
    }

    public set towerBitmapData(arg1: Object /* flash.display.BitmapData */)
    {
        this._bmpTower.bitmapData = arg1;
        return;
    }

    /* internal */ /* var */_bmpTower: Object /* flash.display.Bitmap */;

    /* internal */ /* var */_tfNum: Object /* flash.text.TextField */;
